﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WinForms = System.Windows.Forms;

namespace SharedGenomics.Workbench.Views.WindowsForms
{
    public class OpenFileDialog : IOpenFileDialogView
    {
        private string[] _filters;

        public string Open()
        {
            WinForms.OpenFileDialog ofd = new WinForms.OpenFileDialog();
            ofd.Multiselect = false;

            if (!String.IsNullOrEmpty(this.InitialDirectory))
                ofd.InitialDirectory = this.InitialDirectory;

            if (this._filters != null)
                ofd.Filter = String.Join("|", this._filters);

            WinForms.DialogResult result = ofd.ShowDialog();
            return (result == WinForms.DialogResult.OK) ? ofd.FileName : null;
        }

        public void SetFilters(params string[] filters)
        {
            //TODO: validate arguments...
            this._filters = filters;
        }

        public string InitialDirectory { get; set; }
    }
}
